<?php

/**
 * 手机短信发送记录模型
 * @author yanghj 2014.5.12
 */
class MobilelogModel extends BaseModel
{
    var $table = 'mobile_log';
    var $prikey = 'mobile_log_id';
    var $_name = 'mobilelog';
    
    //检查 手机 / ip 是否发送超过规定条数
    function validate_rightful($mobile, $ip)
    {

        $date = date('Y-m-d');
        $sql = "SELECT COUNT(*) FROM {$this->table} WHERE mobile = '$mobile' and date(send_date)='$date'";
        $total_mobile = $this->getOne($sql); 
        if ($total_mobile >= 5)
            return false;

        $sql = "SELECT COUNT(*) FROM {$this->table} WHERE ip = '$ip' and date(send_date)='$date'";
        $total_ip = $this->getOne($sql);
        if ($total_ip >= 500) {
            return false;
        }
        return true;
    }

}

?>